﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

namespace _4DJackPot
{
    public class WinningNumbers
    {
        public string FirstPrizeNumber { get; set; }
        public string SecondPrizeNumber { get; set; }
        public string ThirdPrizeNumber { get; set; }
        public List<string> SpecialPrizeNumbers { get; set; }
        public List<string> ConsolationPrizeNumbers { get; set; }

        public WinningNumbers(string gameIdString)
        {
            try
            {
                //select query 작성
                string selectQueryString =
                    "SELECT * FROM game_winning_numbers " +
                    "WHERE game_id = " + gameIdString + " ORDER BY prize_type_id";

                DbConn DbConn = new DbConn();
                DataSet resultReadDataSet = DbConn.ReadQuery(selectQueryString);
                SpecialPrizeNumbers = new List<string>();
                ConsolationPrizeNumbers = new List<string>();

                foreach (DataRow row in resultReadDataSet.Tables[0].Rows)
                {
                    if (row["prize_type_id"].ToString().Equals("1"))
                    {
                        this.FirstPrizeNumber = row["number"].ToString();
                    }
                    else if (row["prize_type_id"].ToString().Equals("2"))
                    {
                        this.SecondPrizeNumber = row["number"].ToString();
                    }
                    else if (row["prize_type_id"].ToString().Equals("3"))
                    {
                        this.ThirdPrizeNumber = row["number"].ToString();
                    }
                    else if (row["prize_type_id"].ToString().Equals("4"))
                    {
                        this.SpecialPrizeNumbers.Add(row["number"].ToString());
                    }
                    else if (row["prize_type_id"].ToString().Equals("5"))
                    {
                        this.ConsolationPrizeNumbers.Add(row["number"].ToString());
                    }
                }
            }
            catch (Exception e1)
            {
                FileLog FileLog = new FileLog();
                FileLog.WriteErrorLog(e1.StackTrace + "\n" + e1.Message);
            }
        }
    }
}
